home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC10PlaySound / Play.Init.asm < prev    next >
Encoding:
Assembly Source File  |  1990-06-24  |  12.4 KB  |  358 lines  |  [TEXT/pdos]

  1. *******************************************************************************
  2. *
  3. * PlaySound.init.aii -- Version 3.0
  4. *
  5. * (C)  Copyright Apple Computer, Inc. 1988-1990
  6. * All rights reserved.
  7. *
  8. * Developer Technical Support Apple II Sample Code
  9. *
  10. * by Jim Mensch & Keith Rollin
  11. *
  12. * This file contains standard routines used by all the applications on the DTS
  13. * Demo Disk. This file relies on certain data structures being available in a GLOBALS
  14. * data record in the main file. This file has been modified to not create menus
  15. * and to start up standard file and the sound tools.
  16. *
  17. *******************************************************************************
  18.  
  19.                     EJECT
  20. *******************************************************************************
  21. *
  22. InitTools           start
  23. *
  24. * Description:      Load and initialize the tools needed. Errors are detected
  25. *                   and FatalError is called if any occur. If there aren't any
  26. *                   errors, the list of menu templates is read and the menu-
  27. *                   bar is created.
  28. *
  29. *
  30. * Inputs:           NONE
  31. *
  32. * Outputs:          NONE
  33. *
  34. * External Refs:
  35. *                   Import FatalError
  36. *
  37. * Entry Points:     NONE
  38. *
  39. *******************************************************************************
  40.                     using Globals
  41.  
  42. ;
  43. ;   Tool Direct page offsets here
  44. ;
  45. QDDPage             equ $0000
  46. EMDPage             equ QDDPage+$0300
  47. CtlDPage            equ EMDPage+$0100
  48. MenuDPage           equ CtlDPage+$0100
  49. LEDPage             equ MenuDPage+$0100
  50. SFDPage             equ LEDPage+$0100
  51. SoundDPage          equ SFDPage+$0100
  52. ToolDPSize          equ SoundDPage+$0100
  53.  
  54.                     phk                 ; Save program bank register and
  55.                     plb                 ; load it as the data bank register
  56.  
  57.                     tdc
  58.                     sta MyDP            ; Save direct register
  59.  
  60.                     _TLStartup          ; Start Tool Locator
  61.  
  62.                     pha                 ; Space for result
  63.                     _MMStartup          ; Start memory manager
  64.                     PullWord MyID       ; Save it for later use
  65.  
  66.                     _MTStartup          ; Start up Misc Tools
  67.  
  68.                     _IMStartup          ; Start integer math toolset
  69.  
  70.                     PushLong #ToolTable ; Pointer to Tool table
  71.                     _LoadTools          ; Load all RAM based tools
  72.                     bcc IT0005          ; Carry clear means no error
  73.                     brl FatalError      ; Tools can't be loaded. Fatal error!
  74.  
  75. IT0005              ANOP
  76.  
  77. ; Get memory for Tool Direct pages
  78.  
  79.                     pha                 ; Room for result
  80.                     pha
  81.                     PushLong #ToolDPSize ; Number of bytes needed
  82.                     PushWord MyID       ; ID of this application
  83.                     PushWord #attrLocked+attrFixed+attrPage+attrBank
  84.                     PushLong #0         ; Allocate them in bank 0
  85.                     _NewHandle
  86.                     bcc IT0010          ; Test carry for error
  87.                     brl FatalError      ; If no memory we got a fatal error!
  88.  
  89. IT0010              PullLong DPHandle   ; Retrieve handle to our DPage area
  90.  
  91.                     lda [DPHandle]      ; Dereference the handle to get a ptr
  92.                     sta DPPointer       ; to our direct page area and save it.
  93.  
  94.                     PushWord DPPointer  ; QuickDraw uses 3 pages of Dpage
  95.                     PushWord #ScreenMode ; Used to set all master SCB's
  96.                     PushWord #0         ; Zero means use default buf size
  97.                     PushWord MyID       ; Application ID for allocating data
  98.                     _QDStartup          ; Start QuickDraw, turn on SHR Screen
  99.                     bcc IT0015
  100.                     brl FatalError      ; If it can't be started then bomb
  101.  
  102. IT0015              ANOP
  103.                     lda DPPointer       ; Create address for Event Mgr DPage by
  104.                     clc                 ; loading in the pointer to the start
  105.                     adc #EMDPage        ; of DPage and adding Evt Mgr offset.
  106.                     pha                 ; Now push it on the stack.
  107.                     PushWord #20        ; Size of event queue.
  108.                     PushWord #0         ; MouseClamp values.
  109.                     PushWord #ScreenWidth ; These will clamp mouse to screen
  110.                     PushWord #0         ; area only.
  111.                     PushWord #200
  112.                     PushWord MyID
  113.                     _EMStartup          ; Start the event manager
  114.                     bcc IT0020
  115.                     brl FatalError      ; Event manager is also a must
  116. IT0020              ANOP
  117.                     PushWord MyID
  118.                     _WindStartup
  119.                     bcc IT0025
  120.                     brl FatalError
  121. IT0025              ANOP
  122.                     PushWord MyID
  123.                     lda DPPointer
  124.                     clc
  125.                     adc #CtlDPage
  126.                     pha
  127.                     _CtlStartup
  128.                     bcc IT0030
  129.                     brl FatalError
  130. IT0030              ANOP
  131.  
  132.                     PushWord MyID
  133.                     lda DPPointer
  134.                     clc
  135.                     adc #MenuDPage
  136.                     pha
  137.                     _MenuStartUp
  138.                     bcc IT0035
  139.                     brl FatalError
  140. IT0035              ANOP
  141.                     PushWord MyID
  142.                     lda DPPointer
  143.                     clc
  144.                     adc #LEDPage
  145.                     pha
  146.                     _LEStartUp
  147.                     bcc IT0040
  148.                     brl FatalError
  149. IT0040              ANOP
  150.                     PushWord MyID
  151.                     _DialogStartup
  152.                     bcc IT0045
  153.                     brl FatalError
  154. IT0045              ANOP
  155.                     PushWord MyID
  156.                     lda DPPointer
  157.                     clc
  158.                     adc #SFDPage
  159.                     pha
  160.                     _SFStartUp
  161.                     bcc IT0050
  162.                     brl FatalError
  163. IT0050              ANOP
  164.                     lda DPPointer
  165.                     clc
  166.                     adc #SoundDPage
  167.                     pha
  168.                     _SoundStartup
  169.                     bcc IT0055
  170.                     brl FatalError
  171. IT0055              ANOP
  172.                     _ScrapStartup       ; No errors possible for this call
  173.  
  174.                     _DeskStartup        ; No error possible for this call
  175.  
  176.                     PushLong #0
  177.                     _RefreshDeskTop
  178.  
  179.  
  180.                     RTS
  181.  
  182. ToolTable           dc i2'7'            ; Data Block for LoadTools call
  183.                     dc i2'14,$0100'     ; Window Manager
  184.                     dc i2'15,$0100'     ; Menu Manager
  185.                     dc i2'16,$0100'     ; Control Manager
  186.                     dc i2'20,$0100'     ; LineEdit tool set
  187.                     dc i2'21,$0100'     ; Dialog Manager
  188.                     dc i2'22,$0100'     ; Scrap manager
  189.                     dc i2'23,$0100'     ; standard file
  190.  
  191.                     end
  192.  
  193.                     EJECT
  194. *******************************************************************************
  195. *
  196. FatalError          start
  197. *
  198. * Description:      Routine that is called whenever a tool sends back an error
  199. *                   that can not be recovered from. This routine prints the
  200. *                   error on the screen, waits for a keypress then quits back
  201. *                   to whoever started this application up!
  202. *
  203. *
  204. * Inputs:           A = Error number
  205. *
  206. * Outputs:          NONE (program exits)
  207. *
  208. * External Refs:
  209. *                   Import CloseTools
  210. *
  211. * Entry Points:     NONE
  212. *
  213. *******************************************************************************
  214.                     using Globals
  215.  
  216.                     pha                 ; Push the error code
  217.                     PushLong #ErrNumStr ; Address of storage area
  218.                     PushWord #4         ; Length of string
  219.                     _Int2Hex
  220.  
  221.                     _GrafOff            ; If QD Started, shut off graphics
  222.  
  223.                     PushLong #ErrStr    ; Write error message to the screen
  224.                     _WriteCString
  225.  
  226.                     pha                 ; Space for result
  227.                     PushWord #0         ; No echo
  228.                     _ReadChar           ; Wait for a key to be pressed
  229.                     pla                 ; Discard the key
  230.  
  231.                     jsr CloseTools      ; Shut down all the tools in case
  232. ;                                         any got started up
  233.  
  234.                     _Quit QuitParms     ; Quit back to where we came from.
  235.  
  236.                     brk $FF             ; If the quit fails then just break
  237.                     
  238. ErrStr              dc c'A fatal error has occured $'
  239. ErrNumStr           dc c'xxxx   press any key to exit',i1'0'
  240.  
  241.                     end
  242.  
  243.                     EJECT
  244. *******************************************************************************
  245. *
  246. CloseTools          start
  247. *
  248. * Description:      Shut down the tools I started.
  249. *
  250. *
  251. * Inputs:           NONE
  252. *
  253. * Outputs:          NONE
  254. *
  255. * External Refs:    NONE
  256. *
  257. * Entry Points:     NONE
  258. *
  259. *******************************************************************************
  260.                     using Globals
  261.  
  262.                     _DeskShutDown
  263.                     _ScrapShutDown
  264.                     _SoundShutDown
  265.                     _DialogShutDown
  266.                     _LEShutDown
  267.                     _MenuShutDown
  268.                     _CtlShutDown
  269.                     _WindShutDown
  270.                     _EMShutDown
  271.                     _QDShutDown
  272.                     _MTShutDown
  273.  
  274.                     PushLong DPHandle   ; Dispose of all that DP memory
  275.                     _DisposeHandle
  276.  
  277.                     PushWord MyID
  278.                     _MMShutDown
  279.                     _TLShutDown
  280.  
  281.                     rts
  282.                     end
  283.  
  284.                     EJECT
  285. *******************************************************************************
  286. *
  287. doAbout             start
  288. *
  289. * Description:      Bring up an Alert Dialog box with our name in it.
  290. *
  291. * Inputs:           NONE
  292. *
  293. * Outputs:          NONE
  294. *
  295. * External Refs:    NONE
  296. *
  297. * Entry Points:     NONE
  298. *
  299. *******************************************************************************
  300.                     using Globals
  301.  
  302.                     pha                 ; space for result
  303.                     PushLong #AboutBox  ; pointer to alert template
  304.                     PushLong #0         ; pointer to a filter proc (0=none)
  305.                     _NoteAlert
  306.                     pla                 ; get the item hit and dispose
  307.  
  308.                     rts
  309.  
  310. ; About Box alert template
  311.  
  312. AboutBox            dc i2'30,30,100,590'                    ; for 320 use 30,30,100,290
  313.                     dc i2'1'            ; this is alert # 1
  314.                     dc i1'$80'          ; draw for this stage
  315.                     dc i1'$81'          ; draw for this stage
  316.                     dc i1'$82'          ; draw for this stage
  317.                     dc i1'$83'          ; draw for this stage
  318.                     dc i4'OKButton'     ; ok button for the alert
  319.                     dc i4'AboutTitle'   ; title of the program
  320.                     dc i4'AboutAut'     ; author
  321.                     dc i4'AboutVers'    ; version number string
  322.                     dc i4'0'            ; nil to end the list
  323.  
  324. OKBTitle            dc i1'2',c'OK'
  325. OKButton            dc i2'1'
  326.                     dc i2'50,500,65,550'
  327.                     dc i2'buttonItem'
  328.                     dc i4'OKBTitle'
  329.                     dc i2'0'
  330.                     dc i2'0'            ; item flag
  331.                     dc i4'0'            ; no color table
  332.  
  333. AboutTitle          dc i2'2'
  334.                     dc i2'10,100,20,550'
  335.                     dc i2'statText+itemDisable'
  336.                     dc i4'TitleString'
  337.                     dc i2'0'
  338.                     dc i2'0'            ; item flag
  339.                     dc i4'0'            ; no color table
  340.  
  341. AboutAut            dc i2'3'
  342.                     dc i2'25,100,35,550'
  343.                     dc i2'statText+itemDisable'
  344.                     dc i4'AutString'
  345.                     dc i2'0'
  346.                     dc i2'0'            ; item flag
  347.                     dc i4'0'            ; no color table
  348.  
  349. AboutVers           dc i2'4'
  350.                     dc i2'40,100,50,550'
  351.                     dc i2'statText+itemDisable'
  352.                     dc i4'VersString'
  353.                     dc i2'0'
  354.                     dc i2'0'            ; item flag
  355.                     dc i4'0'            ; no color table
  356.  
  357.                     end
  358.